<?php

namespace server;

class Loader {

    public static function register($locaFunction = null) {
        require_once "./function.php";
        spl_autoload_register($locaFunction ?: "\server\Loader::autoload", true, true);
    }

    public static function autoload($class) {
        if (substr($class, 0, 1) !== "\\") $class = "\\{$class}";
        $classFile = SERVERDIR . str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
        if (file_exists($classFile)) require_once $classFile;
    }

}